home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / Pdmod / modules / xpk / xpk.m < prev   
Encoding:
Text File  |  2002-10-28  |  18.2 KB  |  332 lines

  1. /*
  2. **      $VER: xpk/xpk.h 4.19 (28.10.1998) by SDI
  3. **
  4. **      (C) Copyright 1991-1998 by 
  5. **          Urban Dominik Mueller, Bryan Ford,
  6. **          Christian Schneider, Christian von Roques,
  7. **          Dirk Stöcker
  8. **          All Rights Reserved
  9. */
  10. MODULE  'exec/libraries'
  11. MODULE  'exec/lists'
  12. MODULE  'utility/tagitem'
  13. MODULE  'utility/hooks'
  14.  
  15. #define XPKNAME  'xpkmaster.library'
  16. /***************************************************************************
  17.  *
  18.  *
  19.  *      The packing/unpacking tags
  20.  *
  21.  * (TRUE) or (FALSE) mean the default value given by xpkmaster.library
  22.  *
  23.  */
  24. #define XPK_TagBase     (TAG_USER + ("X"<<8) + "P")
  25. #define XTAG(a )                (XPK_TagBase+a)
  26. /* Caller must supply ONE of these to tell Xpk#?ack where to get data from */
  27. #define XPK_InName        XTAG($01)     /* Process an entire named file */
  28. #define XPK_InFH          XTAG($02)     /* File handle - start from current position */
  29. /* If packing partial file, must also supply InLen */
  30. #define XPK_InBuf         XTAG($03)     /* Single unblocked memory buffer */
  31. /* Must also supply InLen */
  32. #define XPK_InHook        XTAG($04)     /* Call custom Hook to read data */
  33. /* Must also supply InLen, when hook
  34.                                         cannot do! (not for XPK unpacking) */
  35. /* Caller must supply ONE of these to tell Xpk#?ackFile where to send data to */
  36. #define XPK_OutName       XTAG($10)     /* Write (or overwrite) this data file */
  37. #define XPK_OutFH         XTAG($11)     /* File handle - write from current position on */
  38. #define XPK_OutBuf        XTAG($12)     /* Unblocked buffer - must also supply OutBufLen */
  39. #define XPK_GetOutBuf     XTAG($13)     /* Master allocates OutBuf - ti_Data points to buf ptr */
  40. #define XPK_OutHook       XTAG($14)     /* Callback Hook to get output buffers */
  41. /* Other tags for Pack/Unpack */
  42. #define XPK_InLen         XTAG($20)     /* Length of data in input buffer  */
  43. #define XPK_OutBufLen     XTAG($21)     /* Length of output buffer         */
  44. #define XPK_GetOutLen     XTAG($22)     /* ti_Data points to long to receive OutLen    */
  45. #define XPK_GetOutBufLen   XTAG($23)    /* ti_Data points to long to receive OutBufLen */
  46. #define XPK_Password      XTAG($24)     /* Password for de/encoding        */
  47. #define XPK_GetError      XTAG($25)     /* ti_Data points to buffer for error message  */
  48. #define XPK_OutMemType    XTAG($26)     /* Memory type for output buffer   */
  49. #define XPK_PassThru      XTAG($27)     /* Bool: Pass through unrecognized formats on unpack */
  50. #define XPK_StepDown      XTAG($28)     /* Bool: Step down pack method if necessary    */
  51. #define XPK_ChunkHook     XTAG($29)     /* Call this Hook between chunks   */
  52. #define XPK_PackMethod    XTAG($2a)     /* Do a FindMethod before packing  */
  53. #define XPK_ChunkSize     XTAG($2b)     /* Chunk size to try to pack with  */
  54. #define XPK_PackMode      XTAG($2c)     /* Packing mode for sublib to use  */
  55. #define XPK_NoClobber     XTAG($2d)     /* Don't overwrite existing files  */
  56. #define XPK_Ignore        XTAG($2e)     /* Skip this tag                   */
  57. #define XPK_TaskPri       XTAG($2f)     /* Change priority for (un)packing */
  58. #define XPK_FileName      XTAG($30)     /* File name for progress report   */
  59. #define XPK_ShortError    XTAG($31)     /* !!! obsolete !!!                */
  60. #define XPK_PackersQuery   XTAG($32)    /* Query available packers         */
  61. #define XPK_PackerQuery           XTAG($33)     /* Query properties of a packer    */
  62. #define XPK_ModeQuery     XTAG($34)     /* Query properties of packmode    */
  63. #define XPK_LossyOK       XTAG($35)     /* Lossy packing permitted? (FALSE)*/
  64. #define XPK_NoCRC          XTAG($36)    /* Ignore checksum                 */
  65. /* tags added for xfdmaster support (version 4 revision 25) */
  66. #define XPK_Key16         XTAG($37)     /* 16 bit key (unpack only)     */
  67. #define XPK_Key32         XTAG($38)     /* 32 bit key (unpack only)     */
  68. /* tag added to support seek (version 5) */
  69. #define XPK_NeedSeek      XTAG($39)     /* turn on Seek function usage  */
  70. /* preference depending tags added for version 4 - their default value
  71.  may depend on preferences, see <xpk/xpkprefs.h> for more info */
  72. #define XPK_UseXfdMaster   XTAG($40)    /* Use xfdmaster.library (FALSE)   */
  73. #define XPK_UseExternals   XTAG($41)    /* Use packers in extern dir (TRUE)*/
  74. #define XPK_PassRequest    XTAG($42)    /* automatic password req.? (FALSE)*/
  75. #define XPK_Preferences    XTAG($43)    /* use prefs semaphore ? (TRUE)    */
  76. #define XPK_ChunkReport           XTAG($44)     /* automatic chunk report ? (FALSE)*/
  77. /* tags XTAG(0x50) to XTAG(0x6F) are for XpkPassRequest -- see below */
  78. #define XPK_MARGIN      256     /* Safety margin for output buffer      */
  79. /***************************************************************************
  80.  *
  81.  *
  82.  *     The hook function interface
  83.  *
  84.  */
  85. /* Message passed to InHook and OutHook as the ParamPacket */
  86. OBJECT XpkIOMsg
  87.         Type:ULONG,        /* Read/Write/Alloc/Free/Abort       */
  88.         Ptr:PTR,           /* The mem area to read from/write to */
  89.         Size:LONG,         /* The size of the read/write                */
  90.         IOError:ULONG,     /* The IoErr() that occurred         */
  91.         Reserved:ULONG,    /* Reserved for future use           */
  92.         Private1:ULONG,    /* Hook specific, will be set to 0 by */
  93.         Private2:ULONG,    /* master library before first use   */
  94.         Private3:ULONG,
  95.         Private4:ULONG
  96.  
  97. /* The values for XpkIoMsg->Type */
  98. #define XIO_READ     1
  99. #define XIO_WRITE    2
  100. #define XIO_FREE     3
  101. #define XIO_ABORT    4
  102. #define XIO_GETBUF   5
  103. #define XIO_SEEK     6
  104. #define XIO_TOTSIZE  7
  105. /***************************************************************************
  106.  *
  107.  *
  108.  *      The progress report interface
  109.  *
  110.  */
  111. /* Passed to ChunkHook as the ParamPacket */
  112. OBJECT XpkProgress
  113.         Type:ULONG,                     /* Type of report: XPKPROG_#? numbers     */
  114.         PackerName:PTR TO UBYTE,        /* Brief name of packer being used                */
  115.         PackerLongName:PTR TO UBYTE,    /* Descriptive name of packer being used          */
  116.         Activity:PTR TO UBYTE,          /* Packing/unpacking message              */
  117.         FileName:PTR TO UBYTE,          /* Name of file being processed, if available */
  118.         CCur:ULONG,                     /* Amount of packed data already processed        */
  119.         UCur:ULONG,                     /* Amount of unpacked data already processed  */
  120.         ULen:ULONG,                     /* Amount of unpacked data in file                */
  121.         CF:LONG,                        /* Compression factor so far              */
  122.         Done:ULONG,                     /* Percentage done already                        */
  123.         Speed:ULONG,                    /* Bytes per second, from beginning of stream */
  124.         Reserved[8]:ULONG               /* For future use                                 */
  125.  
  126. #define XPKPROG_START   1       /* crunching started */
  127. #define XPKPROG_MID     2       /* somewhere in the mid */
  128. #define XPKPROG_END     3       /* crunching is completed */
  129. /***************************************************************************
  130.  *
  131.  *
  132.  *       The file info block
  133.  *
  134.  */
  135. OBJECT XpkFib
  136.         Type:ULONG,           /* Unpacked, packed, archive?   */
  137.         ULen:ULONG,           /* Uncompressed length          */
  138.         CLen:ULONG,           /* Compressed length            */
  139.         NLen:ULONG,           /* Next chunk len               */
  140.         UCur:ULONG,           /* Uncompressed bytes so far    */
  141.         CCur:ULONG,           /* Compressed bytes so far      */
  142.         ID:ULONG,             /* 4 letter ID of packer        */
  143.         Packer[6]:UBYTE,      /* 4 letter name of packer      */
  144.         SubVersion:UWORD,     /* Required sublib version      */
  145.         MasVersion:UWORD,     /* Required masterlib version   */
  146.         Flags:ULONG,          /* Password?                    */
  147.         Head[16]:UBYTE,       /* First 16 bytes of orig. file */
  148.         Ratio:LONG,           /* Compression ratio            */
  149.         Reserved[8]:ULONG     /* For future use               */
  150.  
  151. #define XPKTYPE_UNPACKED  0             /* Not packed                   */
  152. #define XPKTYPE_PACKED    1             /* Packed file                  */
  153. #define XPKTYPE_ARCHIVE   2             /* Archive                      */
  154. #define XPKFLAGS_PASSWORD  (1<< 0)      /* Password needed              */
  155. #define XPKFLAGS_NOSEEK    (1<< 1)      /* Chunks are dependent         */
  156. #define XPKFLAGS_NONSTD    (1<< 2)      /* Nonstandard file format      */
  157. /* defines added for xfdmaster support (version 4 revision 25) */
  158. #define XPKFLAGS_KEY16    (1<< 3)       /* 16 bit key - for decrunching */
  159. #define XPKFLAGS_KEY32    (1<< 4)       /* 32 bit key - for decrunching */
  160. /***************************************************************************
  161.  *
  162.  *
  163.  *       The error messages
  164.  *
  165.  */
  166. #define XPKERR_OK         0
  167. #define XPKERR_NOFUNC      -1   /* This function not implemented        */
  168. #define XPKERR_NOFILES     -2   /* No files allowed for this function   */
  169. #define XPKERR_IOERRIN     -3   /* Input error happened                 */
  170. #define XPKERR_IOERROUT            -4   /* Output error happened                */
  171. #define XPKERR_CHECKSUM            -5   /* Check sum test failed                */
  172. #define XPKERR_VERSION     -6   /* Packed file's version newer than lib */
  173. #define XPKERR_NOMEM       -7   /* Out of memory                        */
  174. #define XPKERR_LIBINUSE            -8   /* For not-reentrant libraries          */
  175. #define XPKERR_WRONGFORM    -9  /* Was not packed with this library     */
  176. #define XPKERR_SMALLBUF            -10  /* Output buffer too small              */
  177. #define XPKERR_LARGEBUF            -11  /* Input buffer too large               */
  178. #define XPKERR_WRONGMODE    -12 /* This packing mode not supported      */
  179. #define XPKERR_NEEDPASSWD   -13 /* Password needed for decoding         */
  180. #define XPKERR_CORRUPTPKD   -14 /* Packed file is corrupt               */
  181. #define XPKERR_MISSINGLIB   -15 /* Required library is missing          */
  182. #define XPKERR_BADPARAMS    -16 /* Caller's TagList was screwed up      */
  183. #define XPKERR_EXPANSION    -17 /* Would have caused data expansion     */
  184. #define XPKERR_NOMETHOD     -18 /* Cannot find requested method         */
  185. #define XPKERR_ABORTED      -19 /* Operation aborted by user            */
  186. #define XPKERR_TRUNCATED    -20 /* Input file is truncated              */
  187. #define XPKERR_WRONGCPU     -21 /* Better CPU required for this library */
  188. #define XPKERR_PACKED       -22 /* Data are already XPacked             */
  189. #define XPKERR_NOTPACKED    -23 /* Data not packed                      */
  190. #define XPKERR_FILEEXISTS   -24 /* File already exists                  */
  191. #define XPKERR_OLDMASTLIB   -25 /* Master library too old               */
  192. #define XPKERR_OLDSUBLIB    -26 /* Sub library too old                  */
  193. #define XPKERR_NOCRYPT      -27 /* Cannot encrypt                       */
  194. #define XPKERR_NOINFO       -28 /* Can't get info on that packer        */
  195. #define XPKERR_LOSSY        -29 /* This compression method is lossy     */
  196. #define XPKERR_NOHARDWARE   -30 /* Compression hardware required        */
  197. #define XPKERR_BADHARDWARE  -31 /* Compression hardware failed          */
  198. #define XPKERR_WRONGPW      -32 /* Password was wrong                   */
  199. #define XPKERR_UNKNOWN     -33  /* unknown error cause                  */
  200. #define XPKERR_REQTIMEOUT   -34         /* password request reached time out    */
  201. #define XPKERRMSGSIZE   80      /* Maximum size of an error message     */
  202. /***************************************************************************
  203.  *
  204.  *
  205.  *     The XpkQuery() call
  206.  *
  207.  */
  208. OBJECT XpkPackerInfo
  209.         Name[24]:UBYTE,           /* Brief name of the packer          */
  210.         LongName[32]:UBYTE,       /* Full name of the packer           */
  211.         Description[80]:UBYTE,    /* One line description of packer    */
  212.         Flags:ULONG,              /* Defined below                     */
  213.         MaxChunk:ULONG,           /* Max input chunk size for packing  */
  214.         DefChunk:ULONG,           /* Default packing chunk size        */
  215.         DefMode:UWORD             /* Default mode on 0..100 scale      */
  216.  
  217. /* Defines for Flags */
  218. #define XPKIF_PK_CHUNK    (1<< 0)       /* Library supplies chunk packing       */
  219. #define XPKIF_PK_STREAM   (1<< 1)       /* Library supplies stream packing      */
  220. #define XPKIF_PK_ARCHIVE  (1<< 2)       /* Library supplies archive packing     */
  221. #define XPKIF_UP_CHUNK    (1<< 3)       /* Library supplies chunk unpacking     */
  222. #define XPKIF_UP_STREAM   (1<< 4)       /* Library supplies stream unpacking    */
  223. #define XPKIF_UP_ARCHIVE  (1<< 5)       /* Library supplies archive unpacking   */
  224. #define XPKIF_HOOKIO      (1<< 7)       /* Uses full Hook I/O                   */
  225. #define XPKIF_CHECKING    (1<<10)       /* Does its own data checking           */
  226. #define XPKIF_PREREADHDR  (1<<11)       /* Unpacker pre-reads the next chunkhdr */
  227. #define XPKIF_ENCRYPTION  (1<<13)       /* Sub library supports encryption      */
  228. #define XPKIF_NEEDPASSWD  (1<<14)       /* Sub library requires encryption      */
  229. #define XPKIF_MODES       (1<<15)       /* Sub library has different XpkMode's  */
  230. #define XPKIF_LOSSY       (1<<16)       /* Sub library does lossy compression   */
  231. #define XPKIF_NOSEEK     (1<<17)        /* unpacker does not support seeking     */
  232. OBJECT XpkMode
  233.         Next:PTR TO XpkMode,      /* Chain to next descriptor for ModeDesc list*/
  234.         Upto:ULONG,               /* Maximum efficiency handled by this mode   */
  235.         Flags:ULONG,              /* Defined below                             */
  236.         PackMemory:ULONG,         /* Extra memory required during packing      */
  237.         UnpackMemory:ULONG,       /* Extra memory during unpacking             */
  238.         PackSpeed:ULONG,          /* Approx packing speed in K per second      */
  239.         UnpackSpeed:ULONG,        /* Approx unpacking speed in K per second    */
  240.         Ratio:UWORD,              /* CF in 0.1%                           */
  241.         ChunkSize:UWORD,          /* Desired chunk size in K (!!) for this mode*/
  242.         Description[10]:UBYTE     /* 7 character mode description              */
  243.  
  244. /* Defines for XpkMode.Flags */
  245. #define XPKMF_A3000SPEED  (1<< 0)       /* Timings on old standard environment */
  246. /* obsolete */
  247. #define XPKMF_PK_NOCPU    (1<< 1)       /* Packing not heavily CPU dependent    */
  248. #define XPKMF_UP_NOCPU    (1<< 2)       /* Unpacking... (i.e. hardware modes)   */
  249. #define MAXPACKERS  100
  250. OBJECT XpkPackerList
  251.         NumPackers:ULONG,
  252.         Packer[100][6]:UBYTE
  253.  
  254. /***************************************************************************
  255.  *
  256.  *
  257.  *     The XpkSeek() call (library version 5)
  258.  *
  259.  */
  260. #define XPKSEEK_BEGINNING       -1
  261. #define XPKSEEK_CURRENT                 0
  262. #define XPKSEEK_END             1
  263. /***************************************************************************
  264.  *
  265.  *
  266.  *     The XpkPassRequest() call (library version 4)
  267.  *
  268.  */
  269. #define XPK_PassChars     XTAG($50)     /* which chars should be used */
  270. #define XPK_PasswordBuf    XTAG($51)    /* buffer to write password to */
  271. #define XPK_PassBufSize    XTAG($52)    /* size of password buffer */
  272. #define XPK_Key16BitPtr           XTAG($53)     /* pointer to UWORD var for key data */
  273. #define XPK_Key32BitPtr           XTAG($54)     /* pointer to ULONG var for key data */
  274. #define XPK_PubScreen     XTAG($55)     /* pointer to struct Screen */
  275. #define XPK_PassTitle     XTAG($56)     /* Text shown in Screen title */
  276. #define XPK_TimeOut       XTAG($57)     /* Timeout time of requester in seconds */
  277. /* request position and verify tags (version 4 revision 25) */
  278. #define XPK_PassWinLeft           XTAG($58)     /* distance from left screen border */
  279. #define XPK_PassWinTop    XTAG($59)     /* distance form top screen border */
  280. #define XPK_PassWinWidth   XTAG($5A)    /* width of requester window */
  281. #define XPK_PassWinHeight  XTAG($5B)    /* height of requester window */
  282. #define XPK_PassCenter     XTAG($5C)    /* Left and Top are used as center coords */
  283. #define XPK_PassVerify    XTAG($5D)     /* force user to verify password */
  284. /* XPKPASSFF defines for XPK_PassChars. Do not use. Use XPKPASSFLG defines */
  285. #define XPKPASSFF_30x39                 (1<< 0) /* all numbers          */
  286. #define XPKPASSFF_41x46                 (1<< 1) /* chars 'A' to 'F'     */
  287. #define XPKPASSFF_61x66                 (1<< 2) /* chars 'a' to 'f'     */
  288. #define XPKPASSFF_47x5A                 (1<< 3) /* chars 'G' to 'Z'     */
  289. #define XPKPASSFF_67x7A                 (1<< 4) /* chars 'g' to 'z'     */
  290. #define XPKPASSFF_20            (1<< 5) /* space character      */
  291. #define XPKPASSFF_SPECIAL7BIT   (1<< 6) /* special 7 bit chars  */
  292. /* all chars 0x20 to 0x7E without above defined */
  293. #define XPKPASSFF_C0xDE                 (1<< 7) /* upper special chars  */
  294. #define XPKPASSFF_DFxFF                 (1<< 8) /* lower special chars  */
  295. #define XPKPASSFF_SPECIAL8BIT   (1<< 9) /* special 8 bit chars  */
  296. /* all chars 0xA0 to 0xBF */
  297. /* Control characters (0x00 to 0x1F, 0x7F and 0x80 to 0x9F) are not
  298.  * useable. This also means carriage return, linefeed, tab stop and
  299.  * other controls are not usable.
  300.  */
  301. /* flags for XPK_PassChars, XPKPASSFLG_PRINTABLE is default
  302.  *
  303.  * NUMERIC      : numbers
  304.  * HEXADECIMAL  : hex numbers
  305.  * ALPHANUMERIC : numbers and letters
  306.  * INTALPHANUM  : numbers and international letters
  307.  * ASCII7       : 7 Bit ASCII
  308.  * PRINTABLE    : all printable characters
  309.  */
  310. #define XPKPASSFLG_NUMERIC      XPKPASSFF_3$39
  311. #define XPKPASSFLG_HEXADECIMAL  (XPKPASSFF_3$39|XPKPASSFF_41x46|XPKPASSFF_61x66)
  312. #define XPKPASSFLG_ALPHANUMERIC         (XPKPASSFLG_HEXADECIMAL|XPKPASSFF_47x5A|XPKPASSFF_67x7A)
  313. #define XPKPASSFLG_INTALPHANUM  (XPKPASSFLG_ALPHANUMERIC|XPKPASSFF_C$DE|XPKPASSFF_DFxFF)
  314. #define XPKPASSFLG_ASCII7       (XPKPASSFLG_ALPHANUMERIC|XPKPASSFF_SPECIAL7BIT)
  315. #define XPKPASSFLG_PRINTABLE    (XPKPASSFLG_INTALPHANUM|XPKPASSFF_SPECIAL7BIT|XPKPASSFF_SPECIAL8BIT|XPKPASSFF_20)
  316. /***************************************************************************
  317.  *
  318.  *
  319.  *     The XpkAllocObject() call (library version 4)
  320.  *
  321.  * use this always with library version >= 4, do NO longer allocate the
  322.  * structures yourself
  323.  *
  324.  */
  325. #define XPKOBJ_FIB              0       /* XpkFib structure */
  326. #define XPKOBJ_PACKERINFO       1       /* XpkPackerInfo structure */
  327. #define XPKOBJ_MODE             2       /* XpkMode structure */
  328. #define XPKOBJ_PACKERLIST       3       /* XpkPackerList structure */
  329. #endif
  330. /* XPK_XPK_H */
  331.  
  332.